package reviewAlgorithms.math;

public class ConvertToBase7 {
    public static void main(String[] args) {
        int num = 0;
        System.out.println(convertToBase7(num));
    }
    public static String convertToBase7(int num) {
        boolean sign = true;
        if (num < 0){
            num = -num;
            sign = false;
        }
        StringBuilder stringBuilder = new StringBuilder();
        while (num / 7 > 0){
            stringBuilder.append(num % 7);
            num = num / 7;
        }
        stringBuilder.append(num);
        if (!sign){
            stringBuilder.append('-');
        }
        return stringBuilder.reverse().toString();
    }
}
